import { NotFound } from 'lin-mizar';
import { ElevatorModel } from '../model/elevator';

class ElevatorDao {
  async getElevators () {
    const list = await ElevatorModel.findAll({
      order: [
        ['status', 'DESC']
      ]
    });
    console.log(list);
    return list;
  }

  async getElevator (id) {
    const info = await ElevatorModel.findByPk(id);
    if (!info) {
      throw new NotFound({
        code: 10241
      });
    }
    return info;
  }
}

export { ElevatorDao };
